package singleton;

/**
 * Created with IntelliJ IDEA.
 * ClassName: GirlFriendTest
 * Package: singleton
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-23
 * Time: 17:36
 */

public class GirlFriendTest {

    public static void main(String[] args) {

    }

}


//懒汉式
class GirlFriend {

    //1.构造器私有化
    private GirlFriend() {
    }

    //里面造对象
    private static GirlFriend instance = null;

    //3.没有创建 在创建
    public static GirlFriend getInstance() {
        if (instance == null) {
            instance = new GirlFriend();
        }
        return instance;
    }


}
